import { IsArray, IsInt, IsString } from 'class-validator';
import { ApiProperty } from '@nestjs/swagger';

export class LoginUserDto {
  @ApiProperty({
    description: '用户名',
    example: 'admin',
  })
  @IsString()
  username: string;

  @ApiProperty({
    description: '密码',
    example: '123456',
  })
  @IsString()
  password: string;
}

export class LoginUserResponseDto {
  @ApiProperty({
    description: '访问令牌',
    example: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...',
  })
  @IsString()
  access_token: string;

  @ApiProperty({
    description: '用户名',
    example: 'admin',
  })
  @IsString()
  name: string;

  @ApiProperty({
    description: '用户ID',
    example: '123456',
  })
  @IsInt()
  id: number;

  @ApiProperty({
    description: '用户角色',
    example: ['admin', 'user'],
  })
  @IsArray()
  @IsString({ each: true })
  roles?: string[];

  @ApiProperty({
    description: '用户权限',
    example: ['read', 'write'],
  })
  @IsArray()
  @IsString({ each: true })
  permissions?: string[];

  redisEndTime?: number;
}
